/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trabalho_clinte;

import java.net.InetAddress;
import java.net.Socket;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author Nuno
 */
public class Login {
    public final int port = 6000;
    private BufferedReader in;
    String Resposta =null ;
    
    public String connecta( String IP, String user, String pass) throws IOException, InterruptedException{
    
      Socket socket;
      
      socket = new Socket(InetAddress.getByName(IP), port);// socket criada
          
         //socket.setSoTimeout(5000);// Timeout 5secs 
         
         in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out = new PrintWriter(socket.getOutputStream(),true);
        
        out.println(user);
        out.println(pass);

        out.flush();
        
        
        Resposta = in.readLine();// Lê resposta sucesso ou n servidor
        
        System.out.println(Resposta);
        //Thread.sleep(10000);
        out.println("teste");
        socket.close();
      
      
      
        return Resposta;
    
    }
     

    
    
}
